package cn.iocoder.yudao.module.member.user.vo;

import cn.iocoder.yudao.framework.region.vo.setter.CountyAutoSetter;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.List;

@Schema(description = "用户 APP - 用户个人信息 Response VO")
@Data
@NoArgsConstructor
@AllArgsConstructor
public class AppMemberUserInfoRespVO implements CountyAutoSetter {

    @Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
    private Long id;

    @Schema(description = "用户身份码，用户身份的唯一编码", requiredMode = Schema.RequiredMode.REQUIRED, example = "TEST000001")
    private String no;

    @Schema(description = "用户身份码，图片 URL 或 BASE64格式的图片数据")
    private String qrcode;

    @Schema(description = "用户昵称", requiredMode = Schema.RequiredMode.REQUIRED, example = "羡民")
    private String nickname;

    @Schema(description = "用户头像", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://exmaple.local/xxx.png")
    private String avatar;

    @Schema(description = "用户手机号", requiredMode = Schema.RequiredMode.REQUIRED, example = "15285116029")
    private String mobile;

    @Schema(description = "用户性别", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
    private Integer sex;

    @Schema(description = "角色名称，如：普通用户、商家、招商人员、招聘者")
    private String roleName;

    @SuppressWarnings("unused")
    public String getRoleName() {
        if (Boolean.TRUE.equals(getIsMerchant())) {
            return "商家";
        }
        if (Boolean.TRUE.equals(getIsSupplier())) {
            return "厂家";
        }
        if (Boolean.TRUE.equals(getIsWholesaler())) {
            return "投资商";
        }
        if (Boolean.TRUE.equals(getIsAgency())) {
            return "招商人员";
        }
        if (Boolean.TRUE.equals(getIsRecruiter())) {
            return "招聘者";
        }
        return "普通用户";
    }

    @Schema(description = "是否普通会员", requiredMode = Schema.RequiredMode.REQUIRED, example = "false")
    private Boolean isVip;

    @Schema(description = "是否普通商家（店家/零售商）", requiredMode = Schema.RequiredMode.REQUIRED, example = "false")
    private Boolean isMerchant;

    @Schema(description = "是否商家会员", requiredMode = Schema.RequiredMode.REQUIRED, example = "false")
    private Boolean isMerchantVip;

    @Schema(description = "是否招商人员", requiredMode = Schema.RequiredMode.REQUIRED, example = "false")
    private Boolean isAgency;

    @Schema(description = "是否云盟商", requiredMode = Schema.RequiredMode.REQUIRED, example = "false")
    private Boolean isCloudAlliance;

    @Schema(description = "是否供货商（厂家）", requiredMode = Schema.RequiredMode.REQUIRED, example = "false")
    private Boolean isSupplier;

    @Schema(description = "是否批发商（投资商）", requiredMode = Schema.RequiredMode.REQUIRED, example = "false")
    private Boolean isWholesaler;

    @Schema(description = "是否核销员", requiredMode = Schema.RequiredMode.REQUIRED, example = "false")
    private Boolean isVerifier;

    @Schema(description = "是否配送员", requiredMode = Schema.RequiredMode.REQUIRED, example = "false")
    private Boolean isRider;

    @Schema(description = "是否收银员", requiredMode = Schema.RequiredMode.REQUIRED, example = "false")
    private Boolean isCashier;

    @Schema(description = "是否招聘者", requiredMode = Schema.RequiredMode.REQUIRED, example = "false")
    private Boolean isRecruiter;

    @Schema(description = "部门编号")
    private Long deptId;

    @Schema(description = "部门名称")
    private String deptName;

    @Schema(description = "岗位编号")
    private List<Long> postIds;

    @Schema(description = "岗位名称")
    private List<String> postNames;

    @Schema(description = "省份编码", example = "520000")
    private String provinceCode;

    @Schema(description = "城市编码", example = "520100")
    private String cityCode;

    @Schema(description = "区县编码", example = "520100")
    private String countyCode;

    @Schema(description = "省份名称", example = "贵州省")
    private String provinceName;

    public String getProvinceName() {
        if (provinceName == null) {
            provinceName = "";
        }
        return provinceName;
    }

    @Schema(description = "城市名称", example = "贵阳市")
    private String cityName;

    public String getCityName() {
        if (cityName == null) {
            cityName = "";
        }
        return cityName;
    }

    @Schema(description = "区县名称", example = "南明区")
    private String countyName;

    public String getCountyName() {
        if (countyName == null) {
            countyName = "";
        }
        return countyName;
    }

    @Schema(description = "微信的 OpenId", example = "ooths7V-WtbJ_w6aPJb4J2hl18OE")
    private String wxOpenId;

    @SuppressWarnings("unused")
    public String getFullAddress() {
        return getProvinceName() + getCityName() + getCountyName();
    }

}
